varying lowp    vec2	fTexCoord;
varying lowp    vec3    fFogIntensity;


uniform sampler2D   material;
uniform lowp float  fLightIntensity;

const lowp vec4 transparent = vec4(0.0, 0.0, 0.0, 0.0);
const lowp vec3 color_fog = vec3(1.0,1.0,1.0);

void main (void)
{
    lowp vec4 t = texture2D(material, fTexCoord);

    // Avoid too much dark in the night.
    lowp float f = fLightIntensity<0.05 ? 0.05 : fLightIntensity;
    
    // Some one work in Apple said that "Discard is terrible slow. Do not use it." 
    if (t.a<=0.0)
        gl_FragColor = transparent;
    else        
        gl_FragColor = vec4(t.rgb * f * fFogIntensity + color_fog * (1.0-fFogIntensity), t.a);
}